<template>
  <div class="MaterialDemand">
    <div class="banner">
      <div class="wh-1200 auto pl-10">
        <p class="banner_text">解决方案量</p>
        <div class="banner_box">
          <countTo class="banner_box_num" :startVal="startVal" :endVal="TjData.solutionInfoCount" :duration="3000"></countTo>
        </div>
      </div>
    </div>
    <div class="mainContainer wh-1200">
      <div class="main_title mt-40">
        <img src="@/assets/images/product.png" alt />
        <span>解决方案</span>
      </div>
      <!-- 需求搜索Start -->
      <div class="main_search">
        <template v-if="!show">
          <span>关键字：</span>
          <a-input placeholder="请输入关键字" v-model="requestName" />
          <a-button class="ant_btn1" @click="toSearch(true)">搜索</a-button>
        </template>
      </div>
      <!-- 需求搜索End -->
      <!-- 搜索数据Start -->
      <div class="main_searchResult clearfix">
        <div class="f-left search-left">
          <span v-if="displayName != '' && typeof(displayName) != 'undefined'">
            搜索："
            <span class="search-text1">{{displayName}}</span>
            "，
          </span>
          共<span class="search-text2"> {{ this.total }} </span>条数据
        </div>
        <div class="f-right search-right clearfix">
          <a-button @click="receptNum(2)">
            <div class="f-left search-right-icon">
              <div style="margin: -8px 5px 0 0">
                <div>
                  <a-icon type="caret-up" />
                </div>
                <div>
                  <a-icon type="caret-down" class="down" />
                </div>
              </div>
            </div>
            <div class="f-left remainingTime(4)">咨询量</div>
          </a-button>
          <a-button @click="publishTime(6)">
            <div class="f-left search-right-icon">
              <div>
                <a-icon type="caret-up" />
              </div>
              <div>
                <a-icon type="caret-down" class="down" />
              </div>
            </div>
            <div class="f-left remainingTime">发布时间</div>
          </a-button>
        </div>
      </div>
      <!-- 搜索数据End -->
      <!-- 商品列表Start -->
      <div class="goods_list clearfix">
        <div class="goods_list_son" v-for="(item, index) in goodsList" :key="item.id">
          <div class="goods_list_container" @click="ToDetails(item.id)">
            <div class="goods_list_box">
              <div>
                <div class="goods_list_img">
                  <img src="@/assets/images/defult_img.png" alt 
                    v-real-img="item.solutionFile.length > 0 && item.solutionFile[0].fileUrl ? 
                      item.solutionFile[0].fileUrl : '@/assets/images/defult_img.png'"/>
                </div>
              </div>
            </div>
            <p class="clearTitle row-ellipsis">{{ item.solutionName }}</p>
            <p class="produce row-ellipsis-2" :title="item.sketch">{{item.sketch}}</p>

            <div class="company_box flex">
              <span class="faker"></span>
              <span class="title row-ellipsis">{{item.entName}}</span>
              <i class="iconfont icon-gengduojiantou"></i>
            </div>
          </div>
        </div>
      </div>
      <!-- 商品列表End -->
      <no-data v-if="goodsList.length<=0" :Keywords="displayName"></no-data>
      <!-- 分页Start -->
      <div class="tc mt-20 mb-100">
        <a-pagination :show-total="total => `共有 ${total} 条数据`" show-quick-jumper :current="current" show-size-changer :defaultPageSize="PageSize" :pageSizeOptions="['16', '32', '48', '64']"
          :PageSize="PageSize" :total="total" @change="onChange" @showSizeChange="showSizeChange" />
      </div>
      <!-- 分页End -->

    </div>
  </div>
</template>

<script>
import countTo from "vue-count-to";
import NoData from "@/components/Nodata";
import { getSearchSolutionInfoList } from "@/apis/solutionInfo";
import {
  homeTjData,
} from "@/apis/Home";
export default {
  components: {
    countTo,
    NoData,
  },
  created() {
    this.getSearchSolutionInfoList();
    this.GethomeTjData()
  },
  data() {
    return {
      showConnect: false,
      startVal: 0,
      endVal: 0,
      orderByType: null,
      defaultCurrent: 1,
      displayName: "",
      requestName: "",
      show: false,
      current: 1,
      PageSize: 16,
      total: 0,
      goodsList: [],
      TjData:{},
      ActiveindustryList: 0,
      limited: null, //默认供应上限
    };
  },
  methods: {
       // 获取首页统计
    GethomeTjData() {
      homeTjData()
        .then((res) => {
          console.log(res);
          if (res.code == 200) {
            this.TjData = res.data;
          }
        })
        .catch((error) => {});
    },

    // 分页搜索
    onChange(page) {
      this.current = page;
      this.getSearchSolutionInfoList();
    },
    receptNum() {
      if (this.orderByType == 1) {
        this.orderByType = 2;
      } else {
        this.orderByType = 1;
      }
      this.getSearchSolutionInfoList();
    },
    ToDetails(id) {
      this.$router.push({
        path: "/ProgrammeContent",
        query: {
          id: id,
        },
      });
    },
    publishTime() {
      if (this.orderByType == 3) {
        this.orderByType = 6;
      } else {
        this.orderByType = 3;
      }
      this.getSearchSolutionInfoList();
    },
    toSearch() {
      this.displayName = this.requestName;
      this.onChange(1)
    },
    getSearchSolutionInfoList() {
      let _params = {
        current: this.current,
        size: this.PageSize,
        keyword: this.displayName,
        orderByType: this.orderByType,
      };
      getSearchSolutionInfoList(_params)
        .then((res) => {
          if (res.code == 200) {
            this.goodsList = res.data.records;
            this.total = res.data.total;
          }
        })
        .catch((error) => {});
    },
    // 页容量的改变事件
    showSizeChange(current, size) {
      this.PageSize = size;
      this.current = current;
      this.getSearchSolutionInfoList();
    },
  },
  watch: {
    $route(to, from) {
      console.log(to); //到哪去
      this.requestName = to.query.keywords;
      this.toSearch();
    },
  },
};
</script>

<style lang="less" scoped>
.MaterialDemand {
  .banner {
    width: 100%;
    height: 200px;
    background-position: center top;
    background-image: url(./images/banner.png);
    background-repeat: no-repeat;
    background-size: 100% 100%;
    .banner_text {
      padding-top: 40px;
      width: 280px;
      height: 59px;
      font-family: Source Han Sans SC;
      font-size: 36px;
      line-height: 59px;
      color: #ffffff;
    }
    .banner_box {
      width: 300px;
      height: 61px;
      margin-top: 60px;
      background-image: linear-gradient(
        271deg,
        rgba(42, 81, 188, 0) 0%,
        rgba(42, 81, 188, 0.8) 50%,
        rgba(255, 255, 255, 0) 100%
      );
      .banner_box_num {
        width: 100px;
        height: 58px;
        padding-left: 61px;
        font-family: Arial;
        font-size: 54px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 58px;
        letter-spacing: 0px;
        color: #ffffff;
      }
    }
  }
  .mainContainer {
    .main_title {
      img {
        width: 40px;
        height: 40px;
        margin-right: 16px;
        vertical-align: middle;
        margin-top: -10px;
      }
      span {
        font-family: Microsoft YaHei;
        font-size: @font26;
        line-height: @font26;
        font-weight: 700;
        color: @text-color-303;
      }
    }
    .main_search {
      margin-top: 24px;
      margin-bottom: 24px;
      .main_search_input {
        margin-left: 3px;
      }
      .main_search_select {
        width: 164px;
        &:nth-child(1) {
          margin-right: 10px;
        }
      }
      .main_search_price {
        width: 160px !important;
      }
      .main_search_label {
        justify-content: flex-end;
        .btn {
          margin-left: 12px;
        }
      }
      .main_search_radio {
        .item_industrymode {
          padding: 0 15px;
          height: 40px;
          background-color: #ffffff;
          border-radius: 20px;
          border: solid 1px #dcdfe6;
          display: inline-block;
          text-align: center;
          line-height: 40px;
          font-size: 16px;
          color: #909399;
          margin-left: 20px;
          cursor: pointer;
        }
        .item_industrymode_active {
          background-color: #2a51bc;
          display: inline-block;
          text-align: center;
          font-size: 16px;
          color: #ffffff;
        }
      }

      .ant-input {
        width: 500px;
        height: 40px;
      }
      .ant_btn1 {
        margin-left: 12px;
        margin-right: 10px;
        width: 100px;
        height: 40px;
        background-color: #2a51bc;
        box-shadow: 0px 10px 20px 0px rgba(7, 41, 71, 0.16);
        border-radius: 4px;
        color: #fff;
      }
      .show_btn {
        color: #333333;
        cursor: pointer;
        &:hover {
          color: #188af1;
        }
      }
      &:nth-child(4) {
        font-family: Microsoft YaHei;
        font-size: @font16;
        font-weight: normal;
        line-height: 21px;
        color: @text-color-606;
      }
    }
    .main_searchResult {
      height: 70px;
      line-height: 70px;
      background-color: #fff;
      box-shadow: 0px 3px 10px 0px rgba(24, 138, 241, 0.16);
      border-radius: 4px;
      margin-bottom: 32px;
      margin: 2vh 0;
      width: 100%;
      .search-left {
        margin-left: 26px;
        font-size: @font16;
        .search-text1 {
          color: #2a51bc;
        }
        .search-text2 {
          font-size: 16px;
          color: #e9284f;
          font-weight: 700;
        }
      }
      .search-right {
        margin-right: 24px;
        .ant-btn {
          margin-left: 16px;
          width: 120px;
          height: 40px;
          line-height: 1;
          border: solid 1px #188af1;
          color: #188af1;
          font-size: @font16;
          &:hover {
            background-color: #188af1;
            color: #fff;
          }
        }
        .down {
          opacity: 0.5;
        }
        .remainingTime {
          padding-left: 5px;
          line-height: 32px;
        }
        .search-right-icon {
          div {
            width: 14px;
            height: 9px;
          }
          padding-top: 3px;
        }
      }
    }
    .goods_list {
      width: 1200px;
      background: #ffffff;
      .goods_list_son {
        width: 1200px;
        margin: 0 auto;
        width: 24%;
        float: left;
        position: relative;
        margin: 0 12px 10px 0;
        &:hover {
          box-shadow: 6px 6px 20px 0px rgba(24, 138, 241, 0.16);
        }
        .goods_list_container {
          margin: 4px;
          padding: 15px;
          border: solid 1px #e4e7ed;
          border-radius: 4px;
          height: 330px;
          &:hover {
            border: 0 none;
            cursor: pointer;
            img {
              transform: scale(1.1);
              -ms-transform: scale(1.1);
            }
            .clearTitle {
              color: #188af1;
            }
            .icon-gengduojiantou {
              color: #188af1;
            }
          }
          .clearTitle {
            margin: 16px 0 10px 0;
            width: 250px;
            height: 24px;
            font-family: Microsoft YaHei;
            font-size: 18px;
            line-height: 30px;
          }
          .price {
            height: 24px;
            font-family: Microsoft YaHei;
            font-size: 18px;
            line-height: 30px;
            color: #ee6224;
            span {
              float: right;
              display: block;
              padding-top: 5px;
              color: #888888;
              font: 15px Microsoft YaHei;
            }
          }
          .produce {
            width: 250px;
            color: #909399;
            margin: 6px 0;
            -webkit-line-clamp: 2; // 用来限制在一个块元素显示的文本的行数
            display: -webkit-box; // 将对象作为弹性伸缩盒模型显示
            -webkit-box-orient: vertical; //设置或检查伸缩盒对象的子元素的排列方式
            text-overflow: ellipsis; // 在多行文本的情况下，用...隐藏超出范围的文本
            word-break: break-all;
            overflow: hidden;
            height: 40px;
          }
          .produce_type {
            .btn1 {
              height: 24px;
              background-color: #ffffff;
              border: solid 1px #0da9b0;
              border-radius: 10px;
              margin-right: 10px;
              color: #0da9b0;
            }
          }
          .company_box {
            position: relative;
            margin: 6px 0 0 0;
            .faker {
              position: absolute;
              left: 0;
              top: 5px;
              width: 6px;
              height: 18px;
              background-color: #ee6224;
              border-radius: 2px;
            }
            .title {
              width: 195px;
              color: #303133;
              margin: 3px 20px 0 15px;
            }
          }
          .goods_list_box {
            width: 100%;
            height: 174px;
            position: relative;
            text-align: center;
            cursor: pointer;
            .tags {
              position: absolute;
              width: 77px;
              height: 35px;
              line-height: 35px;
              background-color: #ff4e00;
              border-radius: 0px 0px 0px 38px;
              right: -15px;
              top: -16px;
              text-align: right;
              font-size: 16px;
              padding: 0px 10px 0 0;
              color: #ffffff;
              z-index: 6;
            }
            .goods_list_img {
              width: 258px;
              height: 180px;
              background-image: linear-gradient(90deg);
              border-radius: 4px;
              display: flex;
              justify-content: center;
              align-items: center;
              overflow: hidden;
              img {
                width: auto;
                max-height: 180px;
                transition: all 0.8s;
                -ms-transition: all 0.8s;
              }
            }
          }
          .icon-gengduojiantou {
            color: #909399;
            font-size: 18px;
            vertical-align: top;
          }
        }
      }
    }
  }

  .btn {
    width: 100px;
    height: 40px;
  }
}
</style>